<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>canvas绘图</title>
<style>
	body{
		text-align: center;
	}
	#c{
		border: 1px solid #000;
	}	
</style>
</head>
<canvas id="c" width="800" height="600">
</canvas>
<script>
	var ctx=c.getContext("2d");
	var x=0;
	var timer=setInterval(function(){
		ctx.fillStyle="blue";
		ctx.lineWidth=1;		
		ctx.fillRect(x,0,100,100);	
		ctx.clearRect(x-100,0,100,100);
		x+=100;
		if(x>=900){
			x=0;			
		}
	},600);
</script>
<body>
</body>
</html>
